/**
 * 断面
 */
Ext.define('Admin.view.waterOptimum.resultshow.section',{
	extend:'Ext.panel.Panel',
	xtype:'woSection',
	//起别名
	alias:'woSection',
	require:[],
	user:[],
	userCLs:'big-100 small-100',
	layout: {
        type: 'vbox',
        align: 'stretch'
    },
	items: [{
		xtype: 'grid',
		store: {
			xtype: 'store',
			fields:[ 'index1', 'index2', 'index3', 'index4', 'index5', 'index6', 'index7', 'index8', 'index9', 'index10',
				'index11', 'index12', 'index13', 'index14', 'index15', 'index16', 'index17', 'index18', 'index19', 'index20'],
			data: [	{index1: '1月'},
					{index1: '2月'},
					{index1: '3月'},
					{index1: '4月'},
					{index1: '5月'},
					{index1: '6月'},
					{index1: '7月'},
					{index1: '8月'},
					{index1: '9月'},
					{index1: '10月'},
					{index1: '11月'},
					{index1: '12月'},
					{index1: '全年'}]
		},
		border: true,
		flex:1,
		columns: [
			{ text: '月份', dataIndex: 'index1', minWidth: 100, align: 'center' },
			{text: '沙子岭', columns:[
				{ text: '水位', dataIndex: 'index2', minWidth: 100, align: 'center' },
				{ text: '过水流量', dataIndex: 'index3', minWidth: 100, align: 'center' }]},
			{text: '南丰', columns:[
				{ text: '水位', dataIndex: 'index4', minWidth: 100, align: 'center' },
				{ text: '过水流量', dataIndex: 'index5', minWidth: 100, align: 'center' }]},
			{text: '南城', columns:[
				{ text: '水位', dataIndex: 'index6', minWidth: 100, align: 'center' },
				{ text: '过水流量', dataIndex: 'index7', minWidth: 100, align: 'center' }]},
			{text: '黎川', columns:[
				{ text: '水位', dataIndex: 'index8', minWidth: 100, align: 'center' },
				{ text: '过水流量', dataIndex: 'index9', minWidth: 100, align: 'center' }]},
			{text: '廖家湾', columns:[
				{ text: '水位', dataIndex: 'index10', minWidth: 100, align: 'center' },
				{ text: '过水流量', dataIndex: 'index11', minWidth: 100, align: 'center' }]}
		]
	}/*,{
		xtype:'panel',
		margin: '20 0 0 0',
		layout: {
	        type: 'hbox',
	        align: 'stretch'
	    },
		items: [{
			html: '<div id="chart4-section-1" style="width:100%; height:100%;"></div>',
			listeners: {
				resize: {
					fn: function(){
						sectionChart1.reflow();
					}
				},
				boxready: {
					fn: function(obj, width, height, eOpts){
						SectionChart('chart4-section-1', '过流总量图');
					}
				}
			},
			flex:1
		},{
			html: '<div id="chart4-section-2" style="width:100%; height:100%;"></div>',
			listeners: {
				resize: {
					fn: function(){
						sectionChart2.reflow();
					}
				},
				boxready: {
					fn: function(obj, width, height, eOpts){
						sectionChart2 = SectionChart2('chart4-section-2', '水面变化线');
					}
				}
			},
			flex:1
		}],
		flex: 1
	}*/],
	getGridHeader: function(){
		var sectionNames = ['沙子岭',
			'南丰',
			'南城',
			'黎川',
			'廖家湾',
			'娄家村',
			'焦石',
			'李家渡'];
		var output = new Array();
		var inspec = 1;
		output.push({ text: '月份', dataIndex: 'index' + inspec++, minWidth: 100, align: 'center' });
		for(var i=0;i<sectionNames.length;i++){
			output.push({text: sectionNames[i], columns:[
				{ text: '水位', dataIndex: 'index' + inspec++, minWidth: 100, align: 'center', renderer:
						function customRound2(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 2).toFixed(2);
						}
				},
				{ text: '过水流量', dataIndex: 'index' + inspec++, minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 3);
						}
				},]});
		}
		return output;
	},
	getChartConfig1: function(){
		return {
			chart: {
				animation: {
	                duration: 600
	            },
				events: {
	                load: function () {
	                    // set up the updating of the chart each second
	                    var series = this.series[0];
	                    var startLine = 0;

	                    /*if(sectionTimer1 != null)Ext.util.TaskManager.stop(sectionTimer1, true);
	                    sectionTimer1 = {
	                		run: function() {
	                			console.log('timer is running');
	                			if(!sectionReady)return;
	                        	var datas = getSectionTimelyData(startLine);
	                        	for(var i=0;i<sectionNames.length;i++){
	                        		series.data[i].update(datas[i]);
	                        	}
	                        	var kapTitle = '过流总量图 ['+(store4s_1.getAt(startLine).get('index1'))+']';
	                    	//	console.log(kapTitle);
	                    		sectionChart1.setTitle({text: kapTitle});
	                        	startLine++;
	                        	if(startLine >= sectionTimeSet)startLine = 0;
	                		},
	                		interval: 2000
	                    };
	                    Ext.util.TaskManager.start(sectionTimer1);*/

	                    /*if(sectionTimer1 != null)window.clearInterval(sectionTimer1);
	                    sectionTimer1 = setInterval(function () {
	                    	if(!sectionReady)return;
	                    	var datas = getSectionTimelyData(startLine);
	                    	for(var i=0;i<sectionNames.length;i++){
	                    		series.data[i].update(datas[i]);
	                    	}
	                    	var kapTitle = '过流总量图 ['+(store4s_1.getAt(startLine).get('index1'))+']';
	                	//	console.log(kapTitle);
	                		sectionChart1.setTitle({text: kapTitle});
	                    	startLine++;
	                    	if(startLine >= sectionTimeSet)startLine = 0;
	                    }, 2000);*/
	                }
	            }
			},
			title: {
		        text: '过流总量图'
		    },
		    xAxis: {
		        categories: ['sections']
		    },
		    yAxis: {
		    	title: {
		            text: '水量'
		        }
		    },
		    legend:{
		    	enabled: false
		    },
		    series: [{
		        type: 'column',
		        name: '供水',
		        data: []
		    }]
		};
	},
	getChartConfig2: function(){
		return {
		    chart: {
		        type: 'area'
		    },
		    title: {
		        text: '水面变化线'
		    },
		    xAxis: {
		        allowDecimals: false,
		        labels: {
		            formatter: function () {
		                return this.value; // clean, unformatted number for year
		            }
		        }
		    },
		    yAxis: {
		        title: {
		            text: '高程'
		        },
		        labels: {
		            formatter: function () {
		                return this.value / 1000 + 'k';
		            }
		        }
		    },
		    tooltip: {
		        pointFormat: '{series.name} produced <b>{point.y:,.0f}</b><br/>warheads in {point.x}'
		    },
		    plotOptions: {
		        area: {
		            pointStart: 1940,
		            marker: {
		                enabled: false,
		                symbol: 'circle',
		                radius: 2,
		                states: {
		                    hover: {
		                        enabled: true
		                    }
		                }
		            }
		        }
		    },
		    series: [{
		        name: '河道线',
		        data: [null, null, null, null, null, 6, 11, 32, 110, 235, 369, 640,
		            1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
		            27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
		            26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
		            24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
		            22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
		            10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104]
		    }, {
		        name: '水面线',
		        data: [null, null, null, null, null, null, null, null, null, null,
		            5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322,
		            4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478,
		            15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049,
		            33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000,
		            35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000,
		            21000, 20000, 19000, 18000, 18000, 17000, 16000]
		    }]
		};
	}
});
